<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values"></cfg-form>
</template>

<script>
export default {
  name: "pg-form",
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref: "detailTreeView",
      onlyRead: false,
      loading: false,
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
    // attrs: {
    //   type: Object,
    //   default: () => {
    //     return {};
    //   },
    // },
  },
  watch: {},
  computed: {
    attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 3,
        columns: [
          {
            key: "sf_code",
            title: "部门编码",
            minWidth: 100,
            align: "center",
            show: true,
            config: {
              type: "text",readonly:true,
            }
          },
          {
            key: "sf_name",
            title: "部门名称",
            minWidth: 100,
            align: "center",
            show: true,
            config: {
              type: "text",readonly:true,
            }
          },
          {
            key: "brevity",
            title: "部门简码",
            minWidth: 100,
            align: "center",
            show: true,
            config: {
              type: "text",readonly:true,
            }
          },
          // {
          //   key: "leader",
          //   title: "班组组长",
          //   minWidth: 100,
          //   align: "center",
          //   show: true,
          //   config: {
          //     type: "text",readonly:true,
          //   }
          // },
          // {
          //   key: "deptName",
          //   title: "所属部门",
          //   minWidth: 100,
          //   align: "center",
          //   config: { type: "cascader", options: this.anc.deptOptions },
          // },
          {
            key: "remark",
            title: "备注",
            minWidth: 100,
            align: "center",
            show: true,
            config: {
              type: "textarea",
            }
          },
        ],
        rules: {
          sf_name: [
            { required: true, message: "请输入班组名称", trigger: "blur" },
          ],
          sf_code: [
            { required: true, message: "请输入班组编码", trigger: "change" },
          ],
        },
      }
    }
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if (fn) {
          return fn(valid);
        } else {
          return valid;
        }
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped></style>
